De-cruftification continues.
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 21 Feb 2005 12:23:52 +0000 (12:23 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 21 Feb 2005 12:23:52 +0000 (12:23 +0000)
* Replacing Namespace:: functions with NS_ constants
* Replacing make*Link() on strings with make*LinkObj() on Title objects
* Using more legible convenience methods on User and Title
* Start using a common Linker::commentBlock() to wrap the formatComment() bits in the surrounding formatting

18 files changed:
includes/EditPage.php
includes/ImagePage.php
includes/Linker.php
includes/LinksUpdate.php
includes/Skin.php
includes/SkinTemplate.php
includes/SpecialContributions.php
includes/SpecialImagelist.php
includes/SpecialIpblocklist.php
includes/SpecialListusers.php
includes/SpecialMovepage.php
includes/SpecialNewimages.php
includes/SpecialUpload.php
includes/User.php
includes/UserTalkUpdate.php
languages/LanguageFi.php
skins/CologneBlue.php
skins/Standard.php

index 9c69f48..2cd0bdc 100644 (file)
@@ -283,13 +283,14 @@ class EditPage {
                $sk = $wgUser->getSkin();
                $isConflict = false;
                // css / js subpages of user pages get a special treatment
-               $isCssJsSubpage = (Namespace::getUser() == $wgTitle->getNamespace() and preg_match("/\\.(css|js)$/", $wgTitle->getText() ));
+               $isCssJsSubpage = $wgTitle->isCssJsSubpage();
+               
 
                if(!$this->mTitle->getArticleID()) { # new article
                        $wgOut->addWikiText(wfmsg('newarticletext'));
                }
 
-               if( Namespace::isTalk( $this->mTitle->getNamespace() ) ) {
+               if( $this->mTitle->isTalkPage() ) {
                        $wgOut->addWikiText(wfmsg('talkpagetext'));
                }
 
@@ -758,7 +759,7 @@ END
                } else {
                        $name = $id;
                }
-               $link = '[[' . $wgContLang->getNsText( Namespace::getUser() ) .
+               $link = '[[' . $wgContLang->getNsText( NS_USER ) .
                  ":{$name}|{$name}]]";
 
                $wgOut->addWikiText( wfMsg( 'blockedtext', $link, $reason, $ip, $name ) );
index be57183..cec8bd0 100644 (file)
@@ -21,7 +21,7 @@ class ImagePage extends Article {
                                 // available in doDelete etc.
 
        function view() {
-               if ( Namespace::getImage() == $this->mTitle->getNamespace() ) {
+               if( $this->mTitle->getNamespace() == NS_IMAGE ) {
                        $this->openShowImage();
                }
 
@@ -31,7 +31,7 @@ class ImagePage extends Article {
                # follow it with the history list and link list for the image
                # it describes.
 
-               if ( Namespace::getImage() == $this->mTitle->getNamespace() ) {
+               if( $this->mTitle->getNamespace() == NS_IMAGE ) {
                        $this->closeShowImage();
                        $this->imageHistory();
                        $this->imageLinks();
@@ -303,7 +303,7 @@ class ImagePage extends Article {
                        # Image itself is now gone, and database is cleaned.
                        # Now we remove the image description page.
 
-                       $nt = Title::newFromText( $wgContLang->getNsText( Namespace::getImage() ) . ":" . $image );
+                       $nt = Title::makeTitleSafe( NS_IMAGE, $image );
                        $article = new Article( $nt );
                        $article->doDeleteArticle( $reason ); # ignore errors
 
@@ -314,9 +314,9 @@ class ImagePage extends Article {
                $wgOut->setRobotpolicy( 'noindex,nofollow' );
 
                $sk = $wgUser->getSkin();
-               $loglink = $sk->makeKnownLink( $wgContLang->getNsText(
-                 Namespace::getWikipedia() ) .
-                 ':' . wfMsg( 'dellogpage' ), wfMsg( 'deletionlog' ) );
+               $loglink = $sk->makeKnownLinkObj(
+                       Title::makeTitle( NS_SPECIAL, 'Delete/log' ),
+                       wfMsg( 'deletionlog' ) );
 
                $text = wfMsg( 'deletedtext', $deleted, $loglink );
 
@@ -481,8 +481,9 @@ class ImageHistoryList {
                if ( 0 == $user ) {
                        $userlink = $usertext;
                } else {
-                       $userlink = $this->skin->makeLink( $wgContLang->getNsText( Namespace::getUser() ) .
-                                      ':'.$usertext, $usertext );
+                       $userlink = $this->skin->makeLinkObj(
+                               Title::makeTitle( NS_USER, $usertext ),
+                               $usertext );
                }
                $nbytes = wfMsg( 'nbytes', $size );
                $style = $this->skin->getInternalLinkAttributes( $url, $datetime );
@@ -490,10 +491,7 @@ class ImageHistoryList {
                $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a>"
                  . " . . {$userlink} ({$nbytes})";
 
-               if ( '' != $description && '*' != $description ) {
-                       $sk=$wgUser->getSkin();
-                       $s .= $wgContLang->emphasize(' (' . $sk->formatComment($description,$wgTitle) . ')');
-               }
+               $s .= $this->skin->commentBlock( $description, $wgTitle );
                $s .= "</li>\n";
                return $s;
        }
index b02c88b..7f39d4a 100644 (file)
@@ -740,7 +740,7 @@ class Linker {
 
                # format regular and media links - all other wiki formatting
                # is ignored
-               $medians = $wgContLang->getNsText(Namespace::getMedia()).':';
+               $medians = $wgContLang->getNsText( NS_MEDIA ) . ':';
                while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
                        # Handle link renaming [[foo|text]] will show link as "text"
                        if( "" != $match[3] ) {
@@ -769,6 +769,24 @@ class Linker {
                wfProfileOut( $fname );
                return $comment;
        }
+       
+       /**
+        * Wrap a comment in standard punctuation and formatting if
+        * it's non-empty, otherwise return empty string.
+        *
+        * @param string $comment
+        * @param Title $title
+        * @return string
+        * @access public
+        */
+       function commentBlock( $comment, $title = NULL ) {
+               if( $comment == '' ) {
+                       return '';
+               } else {
+                       $formatted = $this->formatComment( $comment, $title );
+                       return " <em>($formatted)</em>";
+               }
+       }
 
        /** @todo document */
        function tocIndent() {
index 8fcca3d..c403340 100644 (file)
@@ -128,7 +128,7 @@ class LinksUpdate {
                
                # Do the insertion
                $sql = '';
-               $image = Namespace::getImage();
+               $image = NS_IMAGE;
                if ( 0 != count ( $add ) ) {
                        $arr = array();
                        foreach ($add as $iname => $val ) {
index 7bc8788..46c2cb9 100644 (file)
@@ -186,9 +186,11 @@ class Skin extends Linker {
        function getHeadScripts() {
                global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs;
                $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
-               if( $wgAllowUserJs && $wgUser->getID() != 0 ) { # logged in
-                       $userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
-                       $userjs = htmlspecialchars($this->makeUrl($userpage.'/'.$this->getSkinName().'.js', 'action=raw&ctype=text/javascript'));
+               if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
+                       $userpage = $wgUser->getUserPage();
+                       $userjs = htmlspecialchars( $this->makeUrl(
+                               $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
+                               'action=raw&ctype=text/javascript'));
                        $r .= '<script type="text/javascript" src="'.$userjs."\"></script>\n";
                }
                return $r;
@@ -225,12 +227,14 @@ class Skin extends Linker {
                $action = $wgRequest->getText('action');
                $s = "@import \"$wgStylePath/$sheet\";\n";
                if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
-               if( $wgAllowUserCss && $wgUser->getID() != 0 ) { # logged in
+               if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
                        if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
                                $s .= $wgRequest->getText('wpTextbox1');
                        } else {
-                               $userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
-                               $s.= '@import "'.$this->makeUrl($userpage.'/'.$this->getSkinName().'.css', 'action=raw&ctype=text/css').'";'."\n";
+                               $userpage = $wgUser->getUserPage();
+                               $s.= '@import "'.$this->makeUrl(
+                                       $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
+                                       'action=raw&ctype=text/css').'";'."\n";
                        }
                }
                $s .= $this->doGetUserStyles();
@@ -321,13 +325,11 @@ class Skin extends Linker {
         * two functions to make it easier to subclass.
         */
        function beforeContent() {
-               global $wgUser, $wgOut;
-
                return $this->doBeforeContent();
        }
 
        function doBeforeContent() {
-               global $wgUser, $wgOut, $wgTitle, $wgContLang, $wgSiteNotice;
+               global $wgOut, $wgTitle, $wgContLang, $wgSiteNotice;
                $fname = 'Skin::doBeforeContent';
                wfProfileIn( $fname );
 
@@ -389,7 +391,7 @@ class Skin extends Linker {
 
        
        function getCategoryLinks () {
-               global $wgOut, $wgTitle, $wgUser, $wgParser;
+               global $wgOut, $wgTitle, $wgParser;
                global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
 
                if( !$wgUseCategoryMagic ) return '' ;
@@ -413,8 +415,6 @@ class Skin extends Linker {
 
                        # Render the array as a serie of links
                        function walkThrough ($tree) {
-                               global $wgUser;
-                               $sk = $wgUser->getSkin();
                                $return = '';
                                foreach($tree as $element => $parent) {
                                        if(empty($parent)) {
@@ -427,7 +427,7 @@ class Skin extends Linker {
                                        # add our current element to the list
                                        $eltitle = Title::NewFromText($element);
                                        # FIXME : should be makeLink() [AV]
-                                       $return .= $sk->makeLink($element, $eltitle->getText()).' &gt; ';
+                                       $return .= $this->makeLinkObj( $eltitle, $eltitle->getText() ) . ' &gt; ';
                                }
                                return $return;
                        }
@@ -452,9 +452,6 @@ class Skin extends Linker {
        # This gets called immediately before the </body> tag.
        #
        function afterContent() {
-               global $wgUser, $wgOut, $wgServer;
-               global $wgTitle, $wgLang;
-
                $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
                return $printfooter . $this->doAfterContent();
        }
@@ -487,7 +484,7 @@ class Skin extends Linker {
                }
 
                if ( $wgOut->isArticleRelated() ) {
-                       if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
+                       if ( $wgTitle->getNamespace() == NS_IMAGE ) {
                                $name = $wgTitle->getDBkey();
                                $image = new Image( $wgTitle->getDBkey() );
                                if( $image->exists() ) {
@@ -516,8 +513,7 @@ class Skin extends Linker {
                # do not show "You have new messages" text when we are viewing our
                # own talk page
 
-                       if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
-                                               $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
+                       if( $wgTitle->equals( $wgUser->getTalkPage() ) ) {
                                $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
                                                wfMsg('newmessageslink') );
                                $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
@@ -627,8 +623,8 @@ class Skin extends Linker {
                $lo = $wgContLang->specialPage( 'Userlogout' );
 
                $s = '';
-               if ( 0 == $wgUser->getID() ) {
-                       if( $wgShowIPinHeader && isset(  $_COOKIE[ini_get('session.name')] ) ) {
+               if ( $wgUser->isAnon() ) {
+                       if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
                                $n = $wgIP;
 
                                $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
@@ -728,7 +724,7 @@ class Skin extends Linker {
                $s = '';
                if ( $wgOut->isArticleRelated() ) {
                        $s .= '<strong>' . $this->editThisPage() . '</strong>';
-                       if ( 0 != $wgUser->getID() ) {
+                       if ( $wgUser->isLoggedIn() ) {
                                $s .= $sep . $this->watchThisPage();
                        }
                        $s .= $sep . $this->talkLink()
@@ -736,8 +732,8 @@ class Skin extends Linker {
                          . $sep . $this->whatLinksHere()
                          . $sep . $this->watchPageLinksLink();
 
-                       if ( $wgTitle->getNamespace() == Namespace::getUser()
-                           || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
+                       if ( $wgTitle->getNamespace() == NS_USER
+                           || $wgTitle->getNamespace() == NS_USER_TALK )
 
                        {
                                $id=User::idFromName($wgTitle->getText());
@@ -1077,7 +1073,7 @@ class Skin extends Linker {
                global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
                return $wgEnableEmail &&
                       $wgEnableUserEmail &&
-                      0 != $wgUser->getID() && # show only to signed in users
+                      $wgUser->isLoggedIn() && # show only to signed in users
                       0 != $id; # we can only email to non-anons ..
 #                     '' != $id->getEmail() && # who must have an email address stored ..
 #                     0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
index d6fa713..45e3082 100644 (file)
@@ -171,11 +171,12 @@ class SkinTemplate extends Skin {
                wfProfileIn( "$fname-stuff" );
                $this->thispage = $this->mTitle->getPrefixedDbKey();
                $this->thisurl = $this->mTitle->getPrefixedURL();
-               $this->loggedin = $wgUser->getID() != 0;
-               $this->iscontent = ($this->mTitle->getNamespace() != Namespace::getSpecial() );
+               $this->loggedin = $wgUser->isLoggedIn();
+               $this->iscontent = ($this->mTitle->getNamespace() != NS_SPECIAL );
                $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit'));
                $this->username = $wgUser->getName();
-               $this->userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
+               $userPage = $wgUser->getUserPage();
+               $this->userpage = $userPage->getPrefixedText();
                $this->userpageUrlDetails = $this->makeUrlDetails($this->userpage);
 
                $this->usercss =  $this->userjs = $this->userjsprev = false;
@@ -573,10 +574,10 @@ class SkinTemplate extends Skin {
                                                'href' => $this->mTitle->getLocalUrl( 'action=delete' )
                                        );
                                }
-                               if ( $wgUser->getID() != 0 ) {
+                               if ( $wgUser->isLoggedIn() ) {
                                        if ( $this->mTitle->userCanMove()) {
                                                $content_actions['move'] = array(
-                                                       'class' => ($this->mTitle->getDbKey() == 'Movepage' and $this->mTitle->getNamespace == Namespace::getSpecial()) ? 'selected' : false,
+                                                       'class' => ($this->mTitle->getDbKey() == 'Movepage' and $this->mTitle->getNamespace == NS_SPECIAL) ? 'selected' : false,
                                                        'text' => wfMsg('move'),
                                                        'href' => $this->makeSpecialUrl('Movepage', 'target='. urlencode( $this->thispage ) )
                                                );
@@ -596,7 +597,7 @@ class SkinTemplate extends Skin {
                        }
                        wfProfileOut( "$fname-live" );
 
-                       if ( $wgUser->getID() != 0 and $action != 'submit' ) {
+                       if ( $wgUser->isLoggedIn() and $action != 'submit' ) {
                                if( !$this->mTitle->userIsWatching()) {
                                        $content_actions['watch'] = array(
                                                'class' => ($action == 'watch' or $action == 'unwatch') ? 'selected' : false,
@@ -861,17 +862,17 @@ class SkinTemplate extends Skin {
                global $wgUser;
                $s = "/* generated user stylesheet */\n";
 
-               if($wgUser->getID() != 0) {
-                       if ( 1 == $wgUser->getOption( "underline" ) ) {
+               if( $wgUser->isLoggedIn() ) {
+                       if ( $wgUser->getOption( "underline" ) ) {
                                $s .= "a { text-decoration: underline; }\n";
                        } else {
                                $s .= "a { text-decoration: none; }\n";
                        }
                }
-               if ( 1 != $wgUser->getOption( "highlightbroken" ) ) {
+               if ( !$wgUser->getOption( "highlightbroken" ) ) {
                        $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
                }
-               if ( 1 == $wgUser->getOption( "justify" ) ) {
+               if ( $wgUser->getOption( "justify" ) ) {
                        $s .= "#bodyContent { text-align: justify; }\n";
                }
                wfProfileOut( $fname );
@@ -885,7 +886,7 @@ class SkinTemplate extends Skin {
                $fname = 'SkinTemplate::getUserJs';
                wfProfileIn( $fname );
                
-               global $wgUser, $wgStylePath;
+               global $wgStylePath;
                $s = '/* generated javascript */';
                $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
                $s .= '/* MediaWiki:'.ucfirst($this->skinname)." */\n";
index efb4f0c..94aa5f5 100644 (file)
@@ -58,7 +58,7 @@ function wfSpecialContributions( $par = '' ) {
        }
        $talk = $nt->getTalkPage();
        if( $talk ) {
-               $ul .= ' (' . $sk->makeLinkObj( $talk, $wgLang->getNsText(Namespace::getTalk(0)) ) . ')';
+               $ul .= ' (' . $sk->makeLinkObj( $talk, $wgLang->getNsText( NS_TALK ) ) . ')';
        }
 
 
index cc42ad4..ae2fe26 100644 (file)
@@ -67,7 +67,7 @@ function wfSpecialImagelist() {
          htmlspecialchars( $wpIlMatch ) . "\" /> " .
          "<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>" );
        $nums = array( 50, 100, 250, 500 );
-       $here = $wgContLang->specialPage( "Imagelist" );
+       $here = Title::makeTitle( NS_SPECIAL, 'Imagelist' );
 
        $fill = "";
        $first = true;
@@ -75,7 +75,7 @@ function wfSpecialImagelist() {
                if ( ! $first ) { $fill .= " | "; }
                $first = false;
 
-               $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
+               $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ),
                  "sort=byname&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
        }
        $text = wfMsg( "showlast", $fill, $byname );
@@ -87,7 +87,7 @@ function wfSpecialImagelist() {
                if ( ! $first ) { $fill .= " | "; }
                $first = false;
 
-               $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
+               $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ),
                  "sort=bysize&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
        }
        $text = wfMsg( "showlast", $fill, $bysize );
@@ -99,7 +99,7 @@ function wfSpecialImagelist() {
                if ( ! $first ) { $fill .= " | "; }
                $first = false;
 
-               $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
+               $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ),
                  "sort=bydate&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
        }
        $text = wfMsg( "showlast", $fill, $bydate );
@@ -109,23 +109,23 @@ function wfSpecialImagelist() {
        while ( $s = $dbr->fetchObject( $res ) ) {
                $name = $s->img_name;
                $ut = $s->img_user_text;
-               if ( 0 == $s->img_user ) { $ul = $ut; }
-               else { $ul = $sk->makeLink( $wgContLang->getNsText(
-                 Namespace::getUser() ) . ":{$ut}", $ut ); }
+               if ( 0 == $s->img_user ) {
+                       $ul = $ut;
+               } else {
+                       $ul = $sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut );
+               }
 
                $ilink = "<a href=\"" . htmlspecialchars( Image::wfImageUrl( $name ) ) .
                  "\">" . htmlspecialchars( $name ) . "</a>";
 
                $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size ) );
                $l = "(" .
-                 $sk->makeKnownLink( $wgContLang->getNsText(
-                 Namespace::getImage() ) . ":{$name}", wfMsg( "imgdesc" ) ) .
+                 $sk->makeKnownLinkObj( Title::makeTitle( NS_IMAGE, $name ),
+                 wfMsg( "imgdesc" ) ) .
                  ") {$ilink} . . {$nb} . . {$ul} . . " .
                  $wgLang->timeanddate( $s->img_timestamp, true );
 
-               if ( "" != $s->img_description ) {
-                       $l .= ' <i>(' . $sk->formatComment( $s->img_description ) . ')</i>';
-               }
+               $l .= $sk->commentBlock( $s->img_description );
                $wgOut->addHTML( "{$l}<br />\n" );
        }
        $wgOut->addHTML( "</p>" );
index c186786..cdc7f84 100644 (file)
@@ -144,7 +144,7 @@ function wfAddRow( $block, $tag ) {
        $addr = $block->mAuto ? "#{$block->mId}" : $block->mAddress;
 
        $name = User::whoIs( $block->mBy );
-       $ulink = $sk->makeKnownLink( $wgContLang->getNsText( Namespace::getUser() ). ":{$name}", $name );
+       $ulink = $sk->makeKnownLinkObj( Title::makeTitle( NS_USER, $name ), $name );
        $formattedTime = $wgLang->timeanddate( $block->mTimestamp, true );
        
        if ( $block->mExpiry === "" ) {
index dcb19e2..559ef6a 100644 (file)
@@ -104,7 +104,7 @@ class ListUsersPage extends QueryPage {
                $group = $dbr->tableName( 'group' );
                $user_groups = $dbr->tableName( 'user_groups' );
                
-               $userspace = Namespace::getUser();
+               $userspace = NS_USER;
                $sql = "SELECT group_name as type, $userspace AS namespace, user_name AS title, user_name as value " .
                        "FROM $user ".
                        "LEFT JOIN $user_groups ON user_id =ug_user " .
@@ -171,7 +171,7 @@ class ListUsersPage extends QueryPage {
  * constructor
  */
 function wfSpecialListusers() {
-       global $wgUser, $wgOut, $wgLang, $wgRequest;
+       global $wgRequest;
 
        list( $limit, $offset ) = wfCheckLimits();
 
index 140b254..a8e2e76 100644 (file)
@@ -17,7 +17,7 @@ function wfSpecialMovepage() {
        global $wgUser, $wgOut, $wgRequest, $action, $wgOnlySysopMayMove;
 
        # check rights. We don't want newbies to move pages to prevents possible attack
-       if ( 0 == $wgUser->getID() or $wgUser->isBlocked() or ($wgOnlySysopMayMove and $wgUser->isNewbie())) {
+       if ( $wgUser->isAnon() or $wgUser->isBlocked() or ($wgOnlySysopMayMove and $wgUser->isNewbie())) {
                $wgOut->errorpage( "movenologin", "movenologintext" );
                return;
        }
@@ -76,7 +76,7 @@ class MovePageForm {
                }
 
                $wgOut->addWikiText( wfMsg( 'movepagetext' ) );
-               if ( ! Namespace::isTalk( $ot->getNamespace() ) ) {
+               if ( !$ot->isTalkPage() ) {
                        $wgOut->addWikiText( wfMsg( 'movepagetalktext' ) );
                }
 
@@ -108,7 +108,7 @@ class MovePageForm {
                        </td>
                </tr>" );
 
-               if ( ! Namespace::isTalk( $ot->getNamespace() ) ) {
+               if ( ! $ot->isTalkPage() ) {
                        $wgOut->addHTML( "
                <tr>
                        <td align='right'>
@@ -211,7 +211,7 @@ class MovePageForm {
        }
 
        function showSuccess() {
-               global $wgOut, $wgUser, $wgRequest, $wgRawHtml;
+               global $wgOut, $wgRequest, $wgRawHtml;
 
                $wgOut->setPagetitle( wfMsg( 'movepage' ) );
                $wgOut->setSubtitle( wfMsg( 'pagemovedsub' ) );
@@ -233,7 +233,7 @@ class MovePageForm {
                        $wgOut->addHTML( "\n<p><strong>" . wfMsg( 'talkexists' ) . "</strong></p>\n" );
                } else {
                        $ot = Title::newFromURL( $oldtitle );
-                       if ( ! Namespace::isTalk( $ot->getNamespace() ) ) {
+                       if ( ! $ot->isTalkPage() ) {
                                $wgOut->addHTML( "\n<p>" . wfMsg( 'talkpagenotmoved', wfMsg( $talkmoved ) ) . "</p>\n" );
                        }
                }
index f738348..55b43f6 100644 (file)
@@ -86,7 +86,7 @@ function wfSpecialNewimages() {
 
                $nt = Title::newFromText( $name, NS_IMAGE );
                $img = Image::newFromTitle( $nt );
-               $ul = $sk->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
+               $ul = $sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut );
 
                $gallery->add( $img, $ul.'<br /><i>'.$wgLang->timeanddate( $s->img_timestamp, true ).'</i><br />' );
                
index 75b12a3..9aa57b8 100644 (file)
@@ -97,7 +97,7 @@ class UploadForm {
                }
                
                /** Various rights checks */
-               if( ( $wgUser->getID() == 0 )
+               if( ( $wgUser->isAnon() )
                         OR $wgUser->isBlocked() ) {
                        $wgOut->errorpage( 'uploadnologin', 'uploadnologintext' );
                        return;
@@ -393,7 +393,7 @@ class UploadForm {
                
                $sk = $wgUser->getSkin();
                $ilink = $sk->makeMediaLink( $this->mUploadSaveName, Image::wfImageUrl( $this->mUploadSaveName ) );
-               $dname = $wgContLang->getNsText( Namespace::getImage() ) . ':'.$this->mUploadSaveName;
+               $dname = $wgContLang->getNsText( NS_IMAGE ) . ':'.$this->mUploadSaveName;
                $dlink = $sk->makeKnownLink( $dname, $dname );
 
                $wgOut->addHTML( '<h2>' . wfMsg( 'successfulupload' ) . "</h2>\n" );
index bcb8934..e5aa81f 100644 (file)
@@ -681,6 +681,26 @@ class User {
                $this->invalidateCache();
        }
 
+       /**
+        * A more legible check for non-anonymousness.
+        * Returns true if the user is not an anonymous visitor.
+        *
+        * @return bool
+        */
+       function isLoggedIn() {
+               return( $this->getID() != 0 );
+       }
+       
+       /**
+        * A more legible check for anonymousness.
+        * Returns true if the user is an anonymous visitor.
+        *
+        * @return bool
+        */
+       function isAnon() {
+               return !$this->isLoggedIn();
+       }
+       
        /**
         * Check if a user is sysop
         * Die with backtrace. Use User:isAllowed() instead.
index 8561388..385275f 100644 (file)
@@ -56,7 +56,7 @@ class UserTalkUpdate {
                $this->mTimestamp = $timestamp;
 
                # If namespace isn't User_talk:, do nothing.
-               if ( $this->mNamespace != Namespace::getTalk(Namespace::getUser() ) ) {
+               if ( $this->mNamespace != NS_USER_TALK ) {
                        return;
                }
 
index 9a5508f..117f324 100644 (file)
@@ -864,10 +864,6 @@ class LanguageFi extends LanguageUtf8 {
                return false;
        }
 
-       function specialPage( $name ) {
-               return $this->getNsText( Namespace::getSpecial() ) . ":" . $name;
-       }
-
        function getQuickbarSettings() {
                global $wgQuickbarSettingsFi;
                return $wgQuickbarSettingsFi;
index a40dd8f..7cf5b28 100644 (file)
@@ -232,7 +232,7 @@ class SkinCologneBlue extends Skin {
                          . $sep . $this->whatLinksHere()
                          . $sep . $this->watchPageLinksLink();
                          
-                       if ( Namespace::getUser() == $tns || Namespace::getTalk(Namespace::getUser()) == $tns ) {
+                       if( $tns == NS_USER || $tns == NS_USER_TALK ) {
                                $id=User::idFromName($wgTitle->getText());
                                if ($id != 0) {
                                        $s .= $sep . $this->userContribsLink();
@@ -247,16 +247,17 @@ class SkinCologneBlue extends Skin {
                $s .= $this->menuHead( "qbmyoptions" );
                if ( 0 != $wgUser->getID() ) {
                        $name = $wgUser->getName();
-                       $tl = $this->makeKnownLink( $wgContLang->getNsText(
-                         Namespace::getTalk( Namespace::getUser() ) ) . ":{$name}",
-                         wfMsg( "mytalk" ) );
-                       if ( 0 != $wgUser->getNewtalk() ) { $tl .= " *"; }
+                       $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
+                               wfMsg( 'mytalk' ) );
+                       if ( $wgUser->getNewtalk() ) {
+                               $tl .= " *";
+                       }
 
-                       $s .= $this->makeKnownLink( $wgContLang->getNsText(
-                         Namespace::getUser() ) . ":{$name}", wfMsg( "mypage" ) )
+                       $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
+                               wfMsg( "mypage" ) )
                          . $sep . $tl
                          . $sep . $this->specialLink( "watchlist" )
-                         . $sep . $this->makeKnownLink( $wgContLang->specialPage( "Contributions" ),
+                         . $sep . $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, "Contributions" ),
                                wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) )            
                          . $sep . $this->specialLink( "preferences" )
                          . $sep . $this->specialLink( "userlogout" );
@@ -269,7 +270,7 @@ class SkinCologneBlue extends Skin {
                  . $sep . $this->specialLink( "imagelist" ) 
                  . $sep . $this->specialLink( "statistics" ) 
                  . $sep . $this->bugReportsLink();
-               if ( 0 != $wgUser->getID() && !$wgDisableUploads ) {
+               if ( $wgUser->isLoggedIn() && !$wgDisableUploads ) {
                        $s .= $sep . $this->specialLink( "upload" );
                }
                global $wgSiteSupportPage;
@@ -278,7 +279,9 @@ class SkinCologneBlue extends Skin {
                              .wfMsg( "sitesupport" )."</a>";
                }
                
-               $s .= $sep . $this->makeKnownLink( $wgContLang->specialPage( "Specialpages" ), wfMsg("moredotdotdot") );
+               $s .= $sep . $this->makeKnownLinkObj(
+                       Title::makeTitle( NS_SPECIAL, 'Specialpages' ),
+                       wfMsg( 'moredotdotdot' ) );
 
                $s .= $sep . "\n</div>\n";
                return $s;
index 1bc379f..820b9f4 100644 (file)
@@ -156,7 +156,7 @@ class SkinStandard extends Skin {
                }
 
 
-               if ($wgUser->getID()) {
+               if( $wgUser->isLoggedIn() ) {
                        $s.= $this->specialLink( 'watchlist' ) ;
                        $s .= $sep . $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
                                wfMsg( 'mycontris' ), 'target=' . wfUrlencode($wgUser->getName() ) );
@@ -204,7 +204,7 @@ class SkinStandard extends Skin {
                                        }
 
                                        $s .= $this->makeLink( $link, $text );
-                               } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
+                               } elseif( $wgTitle->getNamespace() != NS_SPECIAL ) {
                                        # we just throw in a "New page" text to tell the user that he's in edit mode,
                                        # and to avoid messing with the separator that is prepended to the next item
                                        $s .= '<strong>' . wfMsg('newpage') . '</strong>';
@@ -223,7 +223,7 @@ class SkinStandard extends Skin {
                        article with "Watch this article" checkbox disabled, the article is transparently
                        unwatched. Therefore we do not show the "Watch this page" link in edit mode
                        */
-                       if ( 0 != $wgUser->getID() && $articleExists) {
+                       if ( $wgUser->isLoggedIn() && $articleExists) {
                                if($action!='edit' && $action != 'submit' )
                                {
                                        $s .= $sep . $this->watchThisPage();
@@ -245,9 +245,8 @@ class SkinStandard extends Skin {
                                $s .= $sep . $this->watchPageLinksLink();
                        }
 
-                       if ( Namespace::getUser() == $wgTitle->getNamespace()
-                       || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
-                       ) {
+                       if ( NS_USER == $wgTitle->getNamespace()
+                               || $wgTitle->getNamespace() == NS_USER_TALK ) {
 
                                $id=User::idFromName($wgTitle->getText());
                                $ip=User::isIP($wgTitle->getText());
@@ -262,7 +261,7 @@ class SkinStandard extends Skin {
                        $s .= "\n<br /><hr class='sep' />";
                }
 
-               if ( 0 != $wgUser->getID() && ( !$wgDisableUploads || $wgRemoteUploads ) ) {
+               if ( $wgUser->isLoggedIn() && ( !$wgDisableUploads || $wgRemoteUploads ) ) {
                        $s .= $this->specialLink( 'upload' ) . $sep;
                }
                $s .= $this->specialLink( 'specialpages' )